<template>
  <div>
    <van-nav-bar
      title="文字选择"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-cell title="简体中文" is-link class="JTzh" @click="changeLang" />
    <van-cell title="繁体中文" is-link class="FTzh" @click="changeLang" />
    <van-cell title="English" is-link class="en" @click="changeLang" />
  </div>
</template>

<script>
export default {
  name: "LangChoose",
  methods: {
    onClickLeft() {
      this.$router.back(); //返回按钮
    },
    changeLang(e) {
      /* 
        变更语言
      */
      if (e.target.innerText == "简体中文") {
        this.$i18n.locale = "zh";
        localStorage.setItem("lang", "zh");
      } else if (e.target.innerText == "繁体中文") {
        this.$i18n.locale = "zhhk";
        localStorage.setItem("lang", "zhhk");
      } else if (e.target.innerText == "English") {
        this.$i18n.locale = "en";
        localStorage.setItem("lang", "en");
      }
      this.$toast.success("更改成功");
    },
  },
};
</script>

<style scoped>
.JTzh {
  margin-top: 0.3rem;
}
</style>